Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to hash-to-curve draft 16, with some API adjustments #90

Merged
merged 6 commits into from
Jul 21, 2024

Conversation

andrewwhitehead
Copy link
Contributor

  • Adds a Message trait for use by expand_message rather than requiring the message to be a single [u8] (more flexibility for larger message values and no-alloc situations)
  • Allows expand_message to be used with security levels other than k=128
  • Removes lifetime parameters and the separate InitExpandMessage trait
  • Moves unit tests to tests/ for compilation performance

tests/hash_to_curve_g1.rs Outdated Show resolved Hide resolved
@str4d
Copy link
Member

str4d commented Feb 27, 2023

Hey! This PR has been close to the top of our to-review list for months now, but just as it keeps getting close to "hey, we can start working on this now!" some other emergency pushes it back down. Part of the problem is our desire to review the delta from draft 12 to draft 16 and confirm there are no backwards-incompatible changes, but also this PR is very big and requires significant uninterrupted time to review (even though most of it appears to only be test moves, it does add to the review complexity).

I strongly want to get this in, and will continue to try and do so, but we do not have time to review it before the next crate release.

@str4d
Copy link
Member

str4d commented Feb 27, 2023

On the above point, I think it would be significantly easier to review this PR if it was split into two separate PRs: a move-only PR that moves the tests to tests/, and then this PR changing the API.

This was referenced Feb 27, 2023
vmx added a commit to filecoin-project/ref-fvm that referenced this pull request May 24, 2024
The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.
vmx added a commit to filecoin-project/ref-fvm that referenced this pull request May 24, 2024
The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.
Stebalien pushed a commit to filecoin-project/ref-fvm that referenced this pull request May 24, 2024
The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.
rjan90 pushed a commit to filecoin-project/ref-fvm that referenced this pull request Jun 12, 2024
The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.
rjan90 pushed a commit to filecoin-project/ref-fvm that referenced this pull request Jun 12, 2024
The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.
Stebalien pushed a commit to filecoin-project/ref-fvm that referenced this pull request Jun 13, 2024
* Update `filecoin-proofs-api` to v18

Update `filecoin-proofs-api` to v18

* Bump to 3.10.0

Bump to 3.10.0

* Update cargo.lock and changelog

Update cargo.lock and changelog

* fix: remove the pairing feature from fvm_shared (#2009)

The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.

* Update Changelog.md with #2009 backport

Update Changelog.md with #2009 backport

* Update fvm_shared to 3.10.0

Update fvm_shared to 3.10.0 in `testing/integration/Cargo.toml`

* Update fvm_shared to v3.10.0

Update fvm_shared to v3.10.0

* Update cargo.lock

Update cargo.lock by running `cargo check --all`

* Update `shared/CHANGELOG.md`

Update `shared/CHANGELOG.md`

---------

Co-authored-by: Volker Mische <volker.mische@gmail.com>
Stebalien pushed a commit to filecoin-project/ref-fvm that referenced this pull request Jun 13, 2024
* Update filecoin-proofs-api to v18

Update filecoin-proofs-api to v18

* Bump to 2.8.0

Bump to 2.8.0

* Update cargo.lock and changelog

Update cargo.lock and changelog

* fix: remove the pairing feature from fvm_shared (#2009)

The `pairing` feature from the `fvm_shared` crate isn't used. It causes
problems, as it forces the `subtle` dependency to v2.4.1, although the
rest is happy to have v2.5.0.

Here is a detailed dependency graph and issue outline:

`fvm_shared` depends on `bls-signatures`.
In `bls-signatures` we depend on an old version (v0.11) of `hkdf`.
That version depends on `hmac` v0.11, which depends on `crypto-mac` v0.11.
`crypto-mac` v0.11.0 depends on `subtle` v2. That is fine, it would
automatically select v2.5.0.
The problem is that `crypto-mac` v0.11.1 pins `subtle` to exactly v2.4,
therefore v2.5.0 won't be selected.

The obvious thing is to upgrade in`bls-signatures` the version of `hkdf`
to the latest v0.12.
That would make it possible to use `subtle` v2.5.0.
The problem is that such an upgrade is not easily possible.
`hkdf` v0.12 depends on a newer version v0.10 of the `sha2` crate.
Updating that breaks the `bls12_381` crate.
The reason is the current version v0.8.0 of `bls12_381` depends on an old
version v0.9 of the `digest` crate.

The obvious thing is to upgrade in `bls12_381` the version of `digest` to
v0.10.
That would make it possible to get `hkdf` v0.12 built.
But such an upgrade is and open issue at
zkcrypto/bls12_381#102, which mentions that it's
blocked on zkcrypto/bls12_381#90.
That pull request is about updating do the hash-to-curve draft v16, currently
it's using v12.
We use that code path in `bls-signatures`, else we wouldn't enable the
`experimental` feature of `bls12_381`.
So it's even not clear if we'd want such a change to v16.

* Update cargo.lock and Changelog.md

Update cargo.locl and Changelog.md

* Update fvm_shared, cargo.lock and changelog

Update fvm_shared, cargo.lock and changelog

---------

Co-authored-by: Volker Mische <volker.mische@gmail.com>
@str4d
Copy link
Member

str4d commented Jul 21, 2024

The PR has not been split yet by the author, so I am going to take over this PR and do so myself. I'll do the move in a separate PR, and then rebase this PR on top of that.

@str4d
Copy link
Member

str4d commented Jul 21, 2024

Rebased on main to remove the tests/ move from this PR (and gain access to updated CI).

@str4d
Copy link
Member

str4d commented Jul 21, 2024

Force-pushed to fix rustfmt issue.

@str4d
Copy link
Member

str4d commented Jul 21, 2024

Force-pushed to fix benchmarks that were broken by the second commit.

Copy link
Member

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7c6f4bc, except for changes to the tests.

src/hash_to_curve/expand_msg.rs Outdated Show resolved Hide resolved
src/hash_to_curve/expand_msg.rs Show resolved Hide resolved
src/hash_to_curve/expand_msg.rs Show resolved Hide resolved
src/hash_to_curve/expand_msg.rs Show resolved Hide resolved
tests/hash_to_curve_g1.rs Outdated Show resolved Hide resolved
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
@str4d
Copy link
Member

str4d commented Jul 21, 2024

Force-pushed to unswap the test orders, and unwrap test vectors.

Copy link
Member

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed db71a01. I have confirmed that the only functional changes in the draft update (that affect this PR) are additional assertions.

Just so others looking at this repo have a sense of time, this PR took me over half of my Sunday to update and review.

…ting

The draft (and the final RFC) do not explicitly give an upper limit on
the hash output size, but section 5.3.3 says that `expand_message_xmd`
requires that DST is at most 255 bytes, and when given a longer domain
separation tag, to use the output of `H` directly as the DST. To avoid
any ambiguities, we bound the set of `H` we support.
Copy link
Member

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 09466e0. I'm going to open a follow-up PR that migrates to the now-released RFC 9380 and removes the experimental feature flag.

@str4d str4d merged commit 2874b5a into zkcrypto:main Jul 21, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants